package cn.openea.perpartner.common.core.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import cn.openea.perpartner.common.core.utils.DateUtils;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * @author Weird077
 * @description TODO
 * @date 2022-02-08 22:05
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //参数：需要设置的属性；设置的时间；元数据(理解：表中的数据)
        this.setFieldValByName("createtime", DateUtils.getNow(), metaObject);
        this.setFieldValByName("updatetime", DateUtils.getNow(), metaObject);
        this.setFieldValByName("createTime", DateUtils.getNow(), metaObject);
        this.setFieldValByName("updateTime", DateUtils.getNow(), metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updatetime", DateUtils.getNow(), metaObject);
        this.setFieldValByName("updateTime", DateUtils.getNow(), metaObject);
    }
}
